<template>
	<view class="member-center">
		<view class="header">
			<view class="info">
				<view class="left">
					<x-image :defaultImage="require('@/static/avatar.png')" :src="userInfo.avatarUrl" class="x-image"></x-image>
					<view class="aux">
						<view class="name-and-level-img">
						
							<view class="name" v-if="userInfo && userInfo.nickName && userInfo.nickName.length>0">{{userInfo.nickName}}</view>
							<view class="name" v-else>微信用户</view>
							
							<u-icon name="integral-fill" color="#FFFF00" size="20"></u-icon>
						</view>
						<view class="validate-desc" :src="userInfo.avatarUrl">永久有效</view>
					</view>
				</view>
				<view class="right">
					<view class="member-rule" @click="onGotoMemberRule">会员规则</view>
					<u-icon name="arrow-right" size="12"></u-icon>
				</view>
			</view>
		</view>

		<!-- 等级卡片 -->
		<view class="card">
			<image src="@/static/member/vip.png" class="vip-bg"></image>
			<view class="card-content">
				<view class="level">VIP1</view>
			</view>
		</view>

		<view class="seperate-line"></view>

		<!-- 成长任务 -->
		<view class="task-header" v-if="taskList.length>0">
			<view class="title">成长任务</view>
			<u-icon name="arrow-right" size="20"></u-icon>
		</view>
		<view v-for="(item, index) in taskList" class="task-item">
			<view class="left">
				<x-image class="x-image" :src="item.url"></x-image>
				<view class="task-info">
					<view class="name">{{item.name}}</view>
					<view class="desc">每完成1笔订单，获得1点成长值</view>
				</view>
			</view>
			<view class="right">{{item.desc==='待开发' ? '敬请期待' : '去wan'}}</view>
		</view>
		
		<view class="seperate-line"></view>
		
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import XNavigationBar from '@/components/navigationBar/xNavigationBar.vue'
	import XImage from '@/components/image/xImage.vue'

	import {
		ThemeMixin
	} from '@/mixins/theme/xThemeMixin.js'
	export default {
		mixins: [ThemeMixin],
		components: {
			XNavigationBar,
			XImage
		},
		computed: {
			...mapState(['userInfo'])
		},
		data() {
			return {
				taskList: [{
						url: require('@/static/member/order.png'),
						name: '完成下单',
						desc: '待开发', //'每完成1笔订单，获得1点成长值',
					},
					{
						url: require('@/static/member/shopping.png'),
						name: '购买商品',
						desc: '待开发', // 每消费1元获得1点成长值',
					},
					{
						url: require('@/static/member/sign.png'),
						name: '每日签到',
						desc: '待开发',
						// desc: '完成后可获得1点成长值，除此外连续签到还可以获得积分、有会员',
					},
				],
			}
		},

		methods: {
			onGotoMemberRule(){
				uni.navigateTo({
					// /pages/protocol/protocol?id=INTEGRAL_RULE&title=积分规则
					url: '/pages/protocol/protocol?id=MEMBER_PROTOCOL&title=会员权益说明'
				})
			}
		}

	}	
</script>

<!-- 头部个人信息 -->
<style lang="scss" scoped>
	@import "@/mixins/theme/xTheme.scss";

	.header {
		width: 100%;
		height: 320rpx;
		background: $x-theme-card-background;
		display: flex;
		flex-direction: column;

		.info {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 40rpx;

			.left {
				display: flex;

				.x-image {
					margin-left: 32rpx;
					width: 140rpx;
					height: 140rpx;
					border-radius: 70rpx;
					overflow: hidden;
				}

				.aux {
					margin-left: 16rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;

					.name-and-level-img {
						display: flex;

						.name {
							font-size: 32rpx;
							font-family: PingFang-SC-Bold, PingFang-SC;
							font-weight: 500;
							color: #FFF;
						}

						.level-img {
							margin-left: 8rpx;
							width: 32rpx;
							height: 32rpx;
						}
					}

					.validate-desc {
						margin-top: 10rpx;
						font-size: 28rpx;
						font-family: PingFang-SC;
						font-weight: 500;
						color: #A5A5A5;
					}
				}
			}

			.right {
				display: flex;
				margin-right: 16rpx;

				.member-rule {
					font-size: 32rpx;
					font-family: PingFang-SC;
					font-weight: 500;
					color: #A5A5A5;
					margin-right: 8rpx;
				}
			}
		}
	}
</style>


<!-- level-card -->
<style lang="scss" scoped>
	.card {
		position: relative;
		top: -100rpx;
		margin: 0 32rpx;
		border-radius: 16rpx;
		width: 686rpx;
		height: 400rpx;
		overflow: hidden;
		background: #666;

		.vip-bg {
			position: absolute;
			width: 480rpx;
			bottom: -30%;
			right: -20%;
		}

		.card-content {
			position: absolute;
			left: 0rpx;
			top: 0rpx;
			width: 100%;
			height: 100%;
			opacity: 0.9;
			background: linear-gradient(180deg, #79B06C, #81B476);
		}
	}
</style>

<!-- 卡片内容 -->
<style lang="scss" scoped>
	.level {
		display: flex;
		width: 100%;
		height: 100%;
		font-family: PingFang-SC;
		font-size: 80rpx;
		color: white;
		justify-content: center;
		align-items: center;
	}
</style>

<!-- 任务 -->
<style lang="scss" socped>
	.seperate-line {
		height: 20rpx;
		width: 100%;
		background: #F9F9F9;
	}

	.task-header {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		height: 160rpx;
		align-items: center;
		padding: 0rpx 20rpx;

		.title {
			font-size: 36rpx;
			font-family: PingFang-SC-Bold;
			font-weight: 600;
			color: #2D2D2D;
		}
	}

	.task-item {
		margin: 0rpx 32rpx 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.left {
			display: flex;
			align-items: center;

			.x-image {
				width: 80rpx;
				height: 80rpx;
				border-radius: 40rpx;
				overflow: hidden;
			}

			.task-info {
				margin-left: 16rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;

				.name {
					font-size: 32rpx;
					font-family: PingFang-SC-Bold, PingFang-SC;
					font-weight: 600;
					color: #2D2D2D;
					margin-left: 8rpx;
				}

				.desc {
					margin-left: 8rpx;
					margin-top: 10rpx;
					font-size: 28rpx;
					font-family: PingFang-SC;
					font-weight: 500;
					color: #A5A5A5;
				}

			}
		}

		.right {
			font-size: 32rpx;
			font-family: PingFang-SC-Bold;
			font-weight: 600;
			/* margin-right: 32rpx; */
			padding: 4rpx 20rpx;
			background-color: #DBB568;
			color: white;
			height: 60rpx;
			border-radius: 30rpx;
			line-height: 52rpx;
		}
	}
</style>